package com.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;

public class FileUtil {
	
	public static void copy(String regionFilePath, String destPath) {
		try {
			int bytesum = 0;
			int byteread = 0;
			File oldfile = new File(regionFilePath);
			String fileName = oldfile.getName();
			String newFilePath = new File(destPath, fileName).getPath();
			new File(newFilePath);	// 创建新路径文件
			if (oldfile.exists()) { // 文件存在时
				InputStream inStream = new FileInputStream(regionFilePath); // 读入原文件
				FileOutputStream fs = new FileOutputStream(newFilePath);
				byte[] buffer = new byte[1444];
				
				while ((byteread = inStream.read(buffer)) != -1) {
					bytesum += byteread; // 字节数 文件大小
					fs.write(buffer, 0, byteread);
				}
				inStream.close();
				fs.close();
			}
		} catch (Exception e) {
			System.out.println("复制单个文件操作出错");
			e.printStackTrace();

		}
	}

}
